<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/common/common.jsp" %>
</head>
<body class="login-layout">
<div class="main-container">
    <div class="main-content ">
        <div class="row">
            <div class="col-sm-10 col-sm-offset-1">
                <div class="login-container">
                    <div class="space-10"></div>
                    <div class="center">
                        <h2>
                            <span class="red">冀银科技</span>
                            <span class="white" id="id-text2">管理系统</span>
                        </h2>
                    </div>

                    <div class="space-6"></div>

                    <div class="position-relative">
                        <div id="login-box" class="login-box visible widget-box no-border">
                            <div class="widget-body">
                                <div class="widget-main">
                                    <h4 class="header blue lighter bigger">
                                        <i class="ace-icon fa fa-coffee green"></i>
                                        登录账号
                                    </h4>

                                    <div class="space-6"></div>

                                    <form id="loginForm" action="login" method="post">
                                        <fieldset>
                                            <label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" class="form-control"
                                                                   placeholder="请输入登录账号" id="loginName"
                                                                   name="loginName" value=""/>
															<i class="icon-user"></i>
														</span>
                                            </label>

                                            <label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control"
                                                                   placeholder="请输入登录密码" id="password" name="password"
                                                                   value=""/>
															<i class="icon-lock"></i>
														</span>
                                            </label>

                                            <div class="space"></div>

                                            <div class="clearfix">
                                                <button type="submit"
                                                        class="width-35 pull-right btn btn-sm btn-primary">
                                                    <span class="bigger-110">登录</span>
                                                </button>
                                            </div>

                                            <div class="space-4"></div>
                                        </fieldset>
                                    </form>
                                </div><!-- /.widget-main -->
                            </div><!-- /.widget-body -->
                        </div><!-- /.login-box -->
                    </div><!-- /.position-relative -->
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<script type="text/javascript">
    $().ready(function () {
        var $loginForm = $("#loginForm");
        var $loginName = $("#loginName");
        var $password = $("#password");
        var $submit = $("button:submit");

        // 表单验证
        $loginForm.validate({
            rules: {
                loginName: "required",
                password: "required"
            },
            messages: {
                loginName: "登录账号不能为空",
                password: "登录密码不能为空"
            },
            submitHandler: function (form) {
                $.ajax({
                    url: $loginForm.attr("action"),
                    type: $loginForm.attr("method"),
                    data: $loginForm.serialize(),
                    dataType: "json",
                    cache: false,
                    beforeSend: function () {
                        $submit.prop("disabled", true);
                    },
                    success: function (data) {
                    	
                        if (data.status == '0') {
                        	
                            window.parent.location.href = "${basePath}/index"
                        } else {
                            $submit.prop("disabled", false);
                            layer.alert(data.message, {
                                icon: 0,
                                skin: 'layui-layer-lan'
                                ,closeBtn: 0
                            });
                           /* window.parent.location.href = "${basePath}";*/
                        }
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        $submit.prop("disabled", false);
                    }
                });
            }
        });
    });
</script>
</body>
</html>
